package com.kurumi.util;

import java.io.ByteArrayOutputStream;

import net.glxn.qrgen.QRCode;
import net.glxn.qrgen.image.ImageType;
import sun.misc.BASE64Encoder;

public class QrUtil {
	
	public static String qrBase64Str(String url) throws Exception{
		String base64Str = null;
		ByteArrayOutputStream out = null;
	     
		 try {
			 out = QRCode.from(url).to(ImageType.JPG).withSize(250, 250).stream();
		     BASE64Encoder encoder = new BASE64Encoder();  
		        // 返回Base64编码过的字节数组字符串  
		     base64Str = encoder.encode(out.toByteArray()); 
	        
		 	} finally {
				if (null != out) {
					out.close();
				}
			} 
		 
		 return base64Str;
	}
	
	

}
